/**
 * SQL数据库操作
 */

#ifndef   _DB_H_
#define   _DB_H_

#include <stdint.h>

#ifdef	__cplusplus
extern "C" {
#endif

	struct sql_storage_item {
		char field[32];   // 字段
		char format[32];  // 格式
		char value[512];          // 值
	};
	extern int db_insert_item_format(struct sql_storage_item* const _items, const int _items_size, const char* const field, ...);
	extern int db_insert_item(struct sql_storage_item* const _items, const int _items_size, const char* const field, const double value);
	extern int db_insert_item_string(struct sql_storage_item* const _items, const int _items_size, const char* const field, const char* const string_value);
	extern int db_insert_item_int(struct sql_storage_item* const _items, const int _items_size, const char* const field, const int value);
	// 存入数据库
	extern int db_insert_sql(struct sql_storage_item* const _items, const int _items_size, void* const _conn, const char* const tbl_name, const int update_flag);
	extern int db_format_init(const struct sql_storage_item* const _format, struct sql_storage_item* const _items, const int _items_size);
	extern int db_main(void);
	extern int db_insert_test(const char hard_id[], const char sn[]);
	extern int db_update_flag(void);


#ifdef	__cplusplus
}
#endif

#endif   // _DB_H_
